//
//  PS_HomeViewController.m
//  FinanceSupermarket
//
//  Created by 丹丹 on 2018/12/12.
//  Copyright © 2018年 xuezi. All rights reserved.
//

#import "PS_HomeViewController.h"
#import "TYCyclePagerView.h"
#import "TYCyclePagerViewCell.h"
#import "TYPageControl.h"
#import "PS_ButtonMenu.h"
#import "PS_HomeListCell.h"
#import "PS_HomeBannerModel.h"
#import "PS_HomeListModel.h"
#import "BHInfiniteScrollView.h"
#import "PS_WebViewController.h"
#import "PS_DummyStatusView.h"
#import "PS_DaiKuanApplyViewController.h"
#import "PS_WangDaiViewController.h"
#import "PS_HomeWangDaiFanLiCell.h"
#import "PS_HomeWangDaiPaiMingCell.h"
#import "PS_HotImagesTableViewCell.h"
#import "PS_HotVideoTableViewCell.h"
#import "PS_HotContentTableViewCell.h"
#import "PS_WangDaiFanLiModel.h"
#import "PS_WangDaiPaiMingModel.h"
#import "PS_ReMenHuiDaModel.h"
#import "PS_bannerModel.h"
#import "PS_HotTitleTableViewCell.h"
#import "PS_WangDaiViewController.h"
#import "PS_WebViewController.h"
@interface PS_HomeViewController ()<UITableViewDelegate,UITableViewDataSource,UIScrollViewDelegate,TYCyclePagerViewDataSource, TYCyclePagerViewDelegate,menuViewDelegate,BHInfiniteScrollViewDelegate,reloadViewDataDelegete>{
    
    PS_DummyStatusView *dummyView;
    NSString * minsheng_urlStr;
    int num;
    NSString * card_urlStr;
    NSString * rank_urlStr;
    NSString * pingji_urlStr;
}
@property (nonatomic,strong)UIScrollView * backScroll;
@property (nonatomic,strong)UIScrollView * bannerScroll;
@property (nonatomic, strong)UITableView * listTableView;
@property (nonatomic, strong)PS_ButtonMenu * menuView;
@property (nonatomic, strong)NSMutableArray * bannerArray;
@property (nonatomic, strong)NSMutableArray * listArray;
@property (nonatomic, strong)NSMutableArray * ImageArray;
@property (nonatomic, strong)NSMutableArray * messageArray;
@property (nonatomic, strong)NSMutableArray * messageConArray;
@property (nonatomic, strong)NSMutableArray * wangDaiFanLiArray;
@property (nonatomic, strong)NSMutableArray * wangDaiPaiMingArray;
@property (nonatomic, strong)NSMutableArray * reMenHuiDaArray;
@property (nonatomic , strong) BHInfiniteScrollView *infinitePageView;//上面的轮播
@property (nonatomic, strong)UIView * footerView;
@property (nonatomic, strong)UIView * headerView;

@end

@implementation PS_HomeViewController

- (NSMutableArray *)wangDaiFanLiArray{
    
    if (_wangDaiFanLiArray == nil) {
        
        _wangDaiFanLiArray = [NSMutableArray array];
    }
    
    return _wangDaiFanLiArray;
}

- (NSMutableArray *)wangDaiPaiMingArray{
    
    if (_wangDaiPaiMingArray == nil) {
        
        _wangDaiPaiMingArray = [NSMutableArray array];
    }
    return _wangDaiPaiMingArray;
}

- (NSMutableArray *)reMenHuiDaArray{
    
    if (_reMenHuiDaArray == nil) {
        
        _reMenHuiDaArray = [NSMutableArray array];
    }
    return _reMenHuiDaArray;
}
- (UIView *)headerView{
    
    if (_headerView ==nil) {
        
        _headerView = [[UIView alloc]initWithFrame:CGRectMake(0, 0, SCREEN_WIDTH, 275+SafeAreaTopHeight)];
        BHInfiniteScrollView *infinitePageView1 = [BHInfiniteScrollView infiniteScrollViewWithFrame:CGRectMake(0, 0, SCREEN_WIDTH,175+SafeAreaTopHeight) Delegate:self ImagesArray:@[] PlageHolderImage:[UIImage imageNamed:@"arror1"]];
        infinitePageView1.backgroundColor = [UIColor yellowColor];
        infinitePageView1.dotSize = 5;
        infinitePageView1.pageControlAlignmentOffset = CGSizeMake(0, 20);
        infinitePageView1.titleView.textColor = [UIColor whiteColor];
        infinitePageView1.titleView.margin = 30;
        infinitePageView1.titleView.hidden = YES;
        infinitePageView1.scrollTimeInterval = 4.5f;
        infinitePageView1.autoScrollToNextPage = YES;
        infinitePageView1.delegate = self;
        [infinitePageView1 setContentMode:UIViewContentModeScaleToFill];
        [_headerView addSubview:infinitePageView1];//头部广告栏
        _infinitePageView = infinitePageView1;
        
        _menuView = [[PS_ButtonMenu alloc]initWithFrame:CGRectMake(0, CGRectGetMaxY(infinitePageView1.frame), SCREEN_WIDTH, 100)];
        _menuView.delegate = self;
        _menuView.textArr = @[@"贷款申请",@"信用卡申请",@"返利",@"评级"];
        _menuView.imgsArr = @[@"shouyeanniu1",@"shouyeanniu2",@"shouyeanniu3",@"shouyeanniu4"];
        [_headerView addSubview:_menuView];
        
    }
    
    return _headerView;
}
- (UIView *)footerView{

    if (_footerView == nil) {

        _footerView = [[UIView alloc]initWithFrame:CGRectMake(0, CGRectGetMaxY(self.listTableView.frame), SCREEN_WIDTH, 30)];
        _footerView.backgroundColor = RGBCOLOR(238, 238, 238);
        UILabel * lable = [[UILabel alloc]initWithFrame:CGRectMake(0, 7, SCREEN_WIDTH, 15)];
        lable.text = @"已经到底了~~";
        lable.font = [UIFont systemFontOfSize:13];
        lable.textAlignment = NSTextAlignmentCenter;
        lable.textColor = RGBCOLOR(153, 153, 153);
        [_footerView addSubview:lable];
    }

    return _footerView;
}

- (NSMutableArray *)messageConArray{

    if (_messageConArray == nil) {

        _messageConArray = [NSMutableArray array];
    }

    return _messageConArray;
}

- (NSMutableArray *)messageArray{

    if (_messageArray == nil) {

        _messageArray = [NSMutableArray array];
    }

    return _messageArray;
}
- (NSMutableArray *)ImageArray{

    if (_ImageArray == nil) {

        _ImageArray = [NSMutableArray array];

    }

    return _ImageArray;
}
- (NSMutableArray *)bannerArray{

    if (_bannerArray == nil) {

        _bannerArray = [NSMutableArray array];
    }
    return _bannerArray;
}

- (NSMutableArray *)listArray{

    if (_listArray == nil) {

        _listArray = [NSMutableArray array];
    }
    return _listArray;
}

- (UITableView *)listTableView{

    if (_listTableView == nil) {

        _listTableView = [[UITableView alloc]initWithFrame:CGRectMake(0,0, SCREEN_WIDTH,SCREEN_HEIGHT-SafeAreaBottomHeight-49)];
        _listTableView.dataSource = self;
        _listTableView.delegate = self;
        _listTableView.showsVerticalScrollIndicator= NO;
        _listTableView.separatorStyle = UITableViewCellSeparatorStyleNone;
        _listTableView.scrollEnabled = YES;
        _listTableView.tableHeaderView = self.headerView;
        _listTableView.tableFooterView = self.footerView;
    }

    return _listTableView;
}
- (UIScrollView *)backScroll
{
    if (_backScroll == nil) {

        _backScroll = [[UIScrollView alloc]initWithFrame:CGRectMake(0,0, SCREEN_WIDTH, SCREEN_HEIGHT - SafeAreaBottomHeight - 49)];
        _backScroll.showsVerticalScrollIndicator = NO;
        _backScroll.delegate = self;
        _backScroll.backgroundColor =RGBCOLOR(238, 238, 238);
    }

    return _backScroll;
}

- (UIScrollView *)bannerScroll
{
    if (_bannerScroll == nil) {

        _bannerScroll = [[UIScrollView alloc]initWithFrame:CGRectMake(0,0, SCREEN_WIDTH, 175+SafeAreaTopHeight)];
        _bannerScroll.showsHorizontalScrollIndicator = NO;
        _bannerScroll.delegate = self;
        _bannerScroll.backgroundColor = [UIColor blueColor];

    }

    return _bannerScroll;
}

- (void)viewDidLoad {
    [super viewDidLoad];
    //    self.nav_titleLabel.text = @"首页";
    self.nav_btmView.hidden = YES;
    self.nav_backImg.hidden = YES;
    self.nav_backButton.hidden = YES;
    self.view.backgroundColor = RGBCOLOR(238, 238, 238);
    num = 10;
    
    [self.view addSubview:self.listTableView];
    [self loadSearchView];
    [self getHomeData];
    
    self.backScroll.contentSize = CGSizeMake(SCREEN_WIDTH, 1000);

    dummyView = [[PS_DummyStatusView alloc]initWithFrame:CGRectMake(0, SafeAreaTopHeight, SCREEN_WIDTH, SCREEN_HEIGHT - SafeAreaTopHeight - SafeAreaBottomHeight) andImageName:@"kong1" andDummyLabelText:@"亲，暂时没有网络哦~"];
    dummyView.delegate = self;
    dummyView.hidden = YES;
    [self.view addSubview:dummyView];
    // Do any additional setup after loading the view.
}

- (void)loadSearchView{
    
    UIView * backView = [[UIView alloc]initWithFrame:CGRectMake(15, 25, SCREEN_WIDTH-30-65-10, 35)];
    backView.layer.borderWidth = 1;
    backView.layer.borderColor = [UIColor whiteColor].CGColor;
    backView.layer.cornerRadius = 15;
    backView.backgroundColor = [UIColor whiteColor];
    backView.alpha = 0.5;
    [self.listTableView.tableHeaderView addSubview:backView];
    
    
    UITextField * searchTF =[[UITextField alloc]initWithFrame:CGRectMake(15, 25, SCREEN_WIDTH-30-65-10, 35)];
    searchTF.font = [UIFont systemFontOfSize:15];
    searchTF.textColor = [UIColor whiteColor];
    searchTF.layer.borderWidth = 1;
    searchTF.layer.borderColor = [UIColor whiteColor].CGColor;
    searchTF.layer.cornerRadius = 15;
    searchTF.backgroundColor = [UIColor clearColor];
    
    //文本框左视图
    UIView *leftView = [[UIImageView alloc]initWithFrame:CGRectMake(0, 0, 35, 35)];
    leftView.backgroundColor = [UIColor clearColor];
    
    UIImageView * searchLogo = [[UIImageView alloc] initWithFrame:CGRectMake(15, 0, 20, 35)];
    searchLogo.image = [UIImage imageNamed:@"sousuo"];
    searchLogo.contentMode = UIViewContentModeScaleAspectFit;
    [leftView addSubview:searchLogo];
    searchTF.leftView = leftView;
    searchTF.leftViewMode = UITextFieldViewModeAlways;
    
    NSString * placeholderStr = @" 请输入要查询的内容";
    NSMutableAttributedString *placeholder = [[NSMutableAttributedString alloc] initWithString:placeholderStr];
    [placeholder addAttribute:NSForegroundColorAttributeName
                         value:[UIColor whiteColor]
                         range:NSMakeRange(0, placeholderStr.length)];
    searchTF.attributedPlaceholder = placeholder;
    [self.listTableView.tableHeaderView addSubview:searchTF];
    
    UIButton * searchButton = [UIButton buttonWithType:UIButtonTypeCustom];
    searchButton.frame = CGRectMake(CGRectGetMaxX(searchTF.frame)+10, 25, 65, 35);
    searchButton.layer.cornerRadius = 15;
    [searchButton setTitleColor:[UIColor colorWithHexString:@"EE726F"] forState:UIControlStateNormal];
    [searchButton setTitle:@"搜索" forState:UIControlStateNormal];
    searchButton.titleLabel.font = [UIFont systemFontOfSize:15];
    [searchButton setBackgroundColor:[UIColor whiteColor]];
    [searchButton addTarget:self action:@selector(searchAction:) forControlEvents:UIControlEventTouchUpInside];
    [self.listTableView.tableHeaderView addSubview:searchButton];
    
}
- (void)searchAction:(UIButton *)sender{
    
    
}
#pragma mark - 添加轮播图
-(void)createBannerView{

    BHInfiniteScrollView *infinitePageView1 = [BHInfiniteScrollView infiniteScrollViewWithFrame:CGRectMake(0, 0, SCREEN_WIDTH,175+SafeAreaTopHeight) Delegate:self ImagesArray:@[] PlageHolderImage:[UIImage imageNamed:@"arror1"]];

    infinitePageView1.dotSize = 5;
    infinitePageView1.pageControlAlignmentOffset = CGSizeMake(0, 20);
    infinitePageView1.titleView.textColor = [UIColor whiteColor];
    infinitePageView1.titleView.margin = 30;
    infinitePageView1.titleView.hidden = YES;
    infinitePageView1.scrollTimeInterval = 4.5f;
    infinitePageView1.autoScrollToNextPage = YES;
    infinitePageView1.delegate = self;
    [infinitePageView1 setContentMode:UIViewContentModeScaleToFill];
    [self.bannerScroll addSubview:infinitePageView1];//头部广告栏
    _infinitePageView = infinitePageView1;
}
#pragma mark - 轮播图的代理
/** 点击图片*/
- (void)infiniteScrollView:(BHInfiniteScrollView *)infiniteScrollView didSelectItemAtIndex:(NSInteger)index{

//    PS_HomeBannerModel * model = self.bannerArray[index];
//    NSString *url = model.url;
//
//    switch (model.type) {
//        case 0:
//        {
//            if (![url isEqualToString:@"#"]&& url.length>0) {
//
//                PS_WebViewController * VC = [[PS_WebViewController alloc]init];
//                VC.webUrl = url;
//                VC.isFrom = 1;
//                [self.navigationController pushViewController:VC animated:YES];
//
//            }
//        }
//            break;
//        case 1:{
//
//            PS_OnlineApplyViewController *VC =[[PS_OnlineApplyViewController alloc]init];
//            VC.applyType =@"0";
//
//            [self.navigationController pushViewController:VC animated:YES];
//        }
//            break;
//        case 2:{
//
//            PS_PosterViewController *VC =[[PS_PosterViewController alloc]init];
//            [self.navigationController pushViewController:VC animated:YES];
//        }
//            break;
//        case 3:{
//
//            PS_LijiApplyViewController *VC =[[PS_LijiApplyViewController alloc]init];
//            VC.pId = [NSString stringWithFormat:@"%ld",(long)model.product_id];
//            [self.navigationController pushViewController:VC animated:YES];
//        }
//            break;
//
//        default:
//            break;
//    }

}
/** 图片滚动*/
- (void)infiniteScrollView:(BHInfiniteScrollView *)infiniteScrollView didScrollToIndex:(NSInteger)index{

}

- (void)topButtons{

    _menuView = [[PS_ButtonMenu alloc]initWithFrame:CGRectMake(0, CGRectGetMaxY(self->_bannerScroll.frame), SCREEN_WIDTH, 100)];
    _menuView.delegate = self;
    _menuView.textArr = @[@"贷款申请",@"信用卡申请",@"返利",@"评级"];
    _menuView.imgsArr = @[@"shouyeanniu1",@"shouyeanniu2",@"shouyeanniu3",@"shouyeanniu4"];
    [self.backScroll addSubview:_menuView];

}

#pragma mark - delegate

- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView{

    return 3;
}

- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section{
 
    if (section == 0) {
        
        return self.wangDaiFanLiArray.count;
        
    }else if (section == 1){
        
        return self.wangDaiPaiMingArray.count;
        
    }else{
        
        return self.reMenHuiDaArray.count;
    }
}

- (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath{

    if (indexPath.section == 0) {
        
        return 130;
        
    }else if(indexPath.section == 1){
        
        return 40;
    }else{
        
        PS_ReMenHuiDaModel * model = [self.reMenHuiDaArray objectAtIndex:indexPath.row];
        
        if (model.view_type == 1) {
            
            return 90;
            
        }else if (model.view_type == 2){
            
            return 130;
            
        }else if(model.view_type == 3){
            
            return 155;
            
        }else{
            
            return 275;
        }
    }
}
- (CGFloat)tableView:(UITableView *)tableView heightForFooterInSection:(NSInteger)section{

    return 30;
}

-(CGFloat)tableView:(UITableView *)tableView heightForHeaderInSection:(NSInteger)section{
    
    return 55;
}

- (UIView *)tableView:(UITableView *)tableView viewForHeaderInSection:(NSInteger)section{
    
    NSArray * sectionArr = @[@"网贷返利",@"网贷排名",@"热门回答"];
    UIView * backView = [[UIView alloc]initWithFrame:CGRectMake(0, 0, SCREEN_WIDTH, 55)];
    backView.backgroundColor = [UIColor whiteColor];
    
    UIView * line = [[UIView alloc]initWithFrame:CGRectMake(0, 0, SCREEN_WIDTH, 10)];
    line.backgroundColor = [UIColor colorWithHexString:@"efefef"];
    [backView addSubview:line];
    
    
    UILabel * markLabel = [[UILabel alloc]initWithFrame:CGRectMake(15, 20, 100, 25)];
    markLabel.text = [sectionArr objectAtIndex:section];
    markLabel.userInteractionEnabled = YES;
    [backView addSubview:markLabel];
    
    UIImageView * arrowIamge = [[UIImageView alloc]initWithFrame:CGRectMake(SCREEN_WIDTH - 15-7, 25, 7, 15)];
    arrowIamge.image = [UIImage imageNamed:@"xiaofanhui"];
    arrowIamge.userInteractionEnabled = YES;
    [backView addSubview:arrowIamge];
    
    UIButton * button = [UIButton buttonWithType:UIButtonTypeCustom];
    button.frame = CGRectMake(0, 0, SCREEN_WIDTH, 45);
    button.tag = section;
    [button addTarget:self action:@selector(pushNext:) forControlEvents:UIControlEventTouchUpInside];
    [backView addSubview:button];
    
    UIView * line2 = [[UIView alloc]initWithFrame:CGRectMake(15,54, SCREEN_WIDTH-30, 1)];
    line2.backgroundColor = [UIColor colorWithHexString:@"efefef"];
    [backView addSubview:line2];
    return backView;
}
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath{

    if (indexPath.section == 0) {
        
        PS_WangDaiFanLiModel * model = [self.wangDaiFanLiArray objectAtIndex:indexPath.row];
        
        PS_HomeWangDaiFanLiCell * cell = [tableView dequeueReusableCellWithIdentifier:@"PS_HomeWangDaiFanLiCell"];
        if (cell == nil) {
            
            cell = [[[NSBundle mainBundle]loadNibNamed:@"PS_HomeWangDaiFanLiCell" owner:self options:nil]objectAtIndex:0];
            
        }
        
        cell.selectionStyle = UITableViewCellSelectionStyleNone;
        [cell setDataForCell:model];
        return cell;
        
    }else if(indexPath.section == 1){
        
       
        
        PS_HomeWangDaiPaiMingCell * cell = [tableView dequeueReusableCellWithIdentifier:@"PS_HomeWangDaiPaiMingCell"];
        if (cell == nil) {
            
            cell = [[[NSBundle mainBundle]loadNibNamed:@"PS_HomeWangDaiPaiMingCell" owner:self options:nil]objectAtIndex:0];
            
        }
        
        cell.selectionStyle = UITableViewCellSelectionStyleNone;
        
        if (indexPath.row == 0) {
            
            cell.rankLabel.text = @"排名";
            cell.nameLable.text = @"平台";
            cell.scoreLabel.text = @"发展指数";
            cell.rankLabel.textColor = [UIColor colorWithHexString:@"999999"];
            cell.nameLable.textColor = [UIColor colorWithHexString:@"999999"];
            cell.scoreLabel.textColor = [UIColor colorWithHexString:@"999999"];
            
            
        }else{
            
            int n =indexPath.row%2;
            if (n == 1) {
                cell.backView.backgroundColor = [UIColor colorWithHexString:@"f9fbfd"];
            }else{
                cell.backView.backgroundColor = [UIColor whiteColor];
            }
//            cell.rankLabel.text = [NSString stringWithFormat:@"%ld",(long)indexPath.row];
            PS_WangDaiPaiMingModel * model = [self.wangDaiPaiMingArray objectAtIndex:indexPath.row-1];
            [cell setDataForCell:model];
        }
        

        return cell;
        
    }else{
        
        PS_ReMenHuiDaModel * model = [self.reMenHuiDaArray objectAtIndex:indexPath.row];
        
        if (model.view_type == 1) {
            
            
            PS_HotTitleTableViewCell * cell = [tableView dequeueReusableCellWithIdentifier:@"PS_HotTitleTableViewCell"];
            if (cell == nil) {
                
                cell = [[[NSBundle mainBundle]loadNibNamed:@"PS_HotTitleTableViewCell" owner:self options:nil]objectAtIndex:0];
                
            }
            
            cell.selectionStyle = UITableViewCellSelectionStyleNone;
            [cell setDataForCell:model];
            return cell;
            
           
        }else if(model.view_type == 2){
            
            PS_HotContentTableViewCell * cell = [tableView dequeueReusableCellWithIdentifier:@"PS_HotContentTableViewCell"];
            if (cell == nil) {
                
                cell = [[[NSBundle mainBundle]loadNibNamed:@"PS_HotContentTableViewCell" owner:self options:nil]objectAtIndex:0];
                
            }
            
            cell.selectionStyle = UITableViewCellSelectionStyleNone;
            [cell setDataForCell:model];
            return cell;
            
            
            
        }else if(model.view_type == 3){
            
            PS_HotImagesTableViewCell * cell = [tableView dequeueReusableCellWithIdentifier:@"PS_HotImagesTableViewCell"];
            if (cell == nil) {
                
                cell = [[[NSBundle mainBundle]loadNibNamed:@"PS_HotImagesTableViewCell" owner:self options:nil]objectAtIndex:0];
                
            }
            
            cell.selectionStyle = UITableViewCellSelectionStyleNone;
            [cell setDataForCell:model];
            return cell;
            
           
        }else{
            
            PS_HotVideoTableViewCell * cell = [tableView dequeueReusableCellWithIdentifier:@"PS_HotVideoTableViewCell"];
            if (cell == nil) {
                
                cell = [[[NSBundle mainBundle]loadNibNamed:@"PS_HotVideoTableViewCell" owner:self options:nil]objectAtIndex:0];
                
            }
            
            cell.selectionStyle = UITableViewCellSelectionStyleNone;
            [cell.videoButton addTarget:self action:@selector(pushWeb:) forControlEvents:UIControlEventTouchUpInside];
            cell.videoButton.tag = indexPath.row;
            [cell setDataForCell:model];
            return cell;
        }
        
    }
    

}
- (void)pushWeb:(UIButton *)sender{
    
    NSInteger tag = sender.tag;
    PS_ReMenHuiDaModel * model = [self.reMenHuiDaArray objectAtIndex:tag];
    PS_WebViewController * VC = [[PS_WebViewController alloc]init];
    VC.webUrl = model.video;
    VC.isFrom = 3;
    [self.navigationController pushViewController:VC animated:YES];
    
}

-(float)widthForString:(NSString *)value fontSize:(float)fontSize andHeight:(float)height

{

    CGSize sizeToFit = [value sizeWithFont:[UIFont systemFontOfSize:fontSize] constrainedToSize:CGSizeMake(CGFLOAT_MAX, height) lineBreakMode:NSLineBreakByWordWrapping];//此处的换行类型（lineBreakMode）可根据自己的实际情况进行设置

    return sizeToFit.width;

}

- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath{


}
-(void)submitButtonAction:(UIButton*)button{



}

#pragma mark--menuViewDelegate
-(void)menuViewSelectedIndex:(NSInteger)index{

    switch (index) {
        case 1:
        {

            PS_DaiKuanApplyViewController *VC = [[PS_DaiKuanApplyViewController alloc]init];
            [self.navigationController pushViewController:VC animated:YES];
        }
            break;
        case 2:
        {
            PS_WebViewController * VC = [[PS_WebViewController alloc]init];
            VC.isFrom = 5;
            VC.webUrl = card_urlStr;
            [self.navigationController pushViewController:VC animated:YES];

        }
            break;
        case 3:
        {
            PS_WangDaiViewController * VC = [[PS_WangDaiViewController alloc]init];
            [self.navigationController pushViewController:VC animated:YES];

        }
            break;
        case 4:
        {
            PS_WebViewController * VC = [[PS_WebViewController alloc]init];
            VC.isFrom = 6;
            VC.webUrl = pingji_urlStr;
            [self.navigationController pushViewController:VC animated:YES];

        }
            break;

        default:
            break;
    }


}

- (void)pushNext:(UIButton *)sender{
    
    NSInteger tag = sender.tag;
    switch (tag) {
        case 0:{
            
            PS_WangDaiViewController * VC = [[PS_WangDaiViewController alloc]init];
            [self.navigationController pushViewController:VC animated:YES];
        }
            
            break;
        case 1:
        {
            PS_WebViewController * VC = [[PS_WebViewController alloc]init];
            VC.isFrom = 7;
            VC.webUrl = rank_urlStr;
            [self.navigationController pushViewController:VC animated:YES];
        }
            break;
        case 2:
            
            break;
            
        default:
            break;
    }
}
- (void)reloadViewData{

    self->dummyView.hidden = YES;
}

- (void)viewWillAppear:(BOOL)animated{

    [super viewWillAppear:animated];

}

- (void)viewWillDisappear:(BOOL)animated{

    [super viewWillDisappear:animated];

}

- (void)getHomeData{
    
    NSUserDefaults * db = [NSUserDefaults standardUserDefaults];
    NSString * userid = [db objectForKey:@"userid"];
    if (userid.length == 0) {
        userid = @"0";
    }
    
    [Utils post:SHOUYE parameters:@{@"uid":userid} success:^(NSInteger recode, id jsonObject) {
        
        NSDictionary * dataDic = [jsonObject objectForKey:@"data"];
        
        self->card_urlStr = [dataDic objectForKey:@"card_url"];
        self->rank_urlStr = [dataDic objectForKey:@"rank_url"];
        self->pingji_urlStr = [dataDic objectForKey:@"pingji_url"];
        
        NSArray * bannerArr = [dataDic objectForKey:@"banner"];
        
        for (NSDictionary * dic in bannerArr) {
            
            PS_bannerModel * model = [PS_bannerModel mj_objectWithKeyValues:dic];
            model.bannerid = [[dic objectForKey:@"id"]integerValue];
            [self.bannerArray addObject:model];
            [self.ImageArray addObject:model.code];
        }
        
        self->_infinitePageView.imagesArray = self.ImageArray;
        
        NSArray * articleArr = [dataDic objectForKey:@"article"];
        for (NSDictionary *dic  in articleArr) {
            
            PS_ReMenHuiDaModel * model = [PS_ReMenHuiDaModel mj_objectWithKeyValues:dic];
            model.articleid = [dic objectForKey:@"id"];
            [self.reMenHuiDaArray addObject:model];
        }
        
        NSArray * rankArr = [dataDic objectForKey:@"rank"];
        
        for (NSDictionary *dic  in rankArr) {
            
            PS_WangDaiPaiMingModel * model = [PS_WangDaiPaiMingModel mj_objectWithKeyValues:dic];
            model.rankid = [[dic objectForKey:@"id"]integerValue];
            [self.wangDaiPaiMingArray addObject:model];
        }
        
        NSArray * merchantArr = [dataDic objectForKey:@"merchant"];
        
        for (NSDictionary *dic  in merchantArr) {
            
            PS_WangDaiFanLiModel * model = [PS_WangDaiFanLiModel mj_objectWithKeyValues:dic];
            model.merchantid = [[dic objectForKey:@"id"]integerValue];
            [self.wangDaiFanLiArray addObject:model];
        }
        
        [self.listTableView reloadData];
        
    } failure:^(NSInteger recode, NSError *error) {
        
    }];
}
@end
